﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddProductIn.aspx.cs" Inherits="MemberMgr.Website.Product.AddProductIn" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script type="text/javascript">
        var triggerHandler = function(el, trigger, index) {
            switch (index) {
                case 0:
                    tfProductName.setValue('');
                    fpProductInfo.getForm().reset();
                    fpProductIn.getForm().reset();
                    break;
                case 1:
                    winDetail.show();
                    break;
            }
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" Locale="zh-CN" />
    <ext:Store ID="storeProduct" runat="server" OnRefreshData="storeProduct_RefreshData">
        <Reader>
            <ext:JsonReader IDProperty="ID">
                <Fields>
                    <ext:RecordField Name="PRODUCTNAME" />
                    <ext:RecordField Name="PRODUCTTYPE" />
                    <ext:RecordField Name="MAKER" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Viewport ID="Viewport1" runat="server" Layout="fit">
        <Items>
            <ext:FormPanel ID="fpProductInfo" runat="server" AutoHeight="true" Title="商品基本信息"
                Padding="5" MonitorResize="true" LabelWidth="160">
                <Items>
                    <ext:TriggerField ID="tfProductName" runat="server" FieldLabel="商品名称" DataIndex="Productname">
                        <Triggers>
                            <ext:FieldTrigger Icon="Clear" Qtip="清除" />
                            <ext:FieldTrigger Icon="Search" Qtip="查询商品" />
                        </Triggers>
                        <Listeners>
                            <TriggerClick Fn="triggerHandler" />
                        </Listeners>
                    </ext:TriggerField>
                    <ext:CompositeField runat="server" FieldLabel="商品种类 / 制造商 / 单价" AnchorHorizontal="100%"
                        ReadOnly="true">
                        <Items>
                            <ext:TextField runat="server" ID="txtProductType" Flex="1" ReadOnly="true" Enabled="false" DataIndex="Producttype" />
                            <ext:TextField runat="server" ID="txtMaker" Flex="1" ReadOnly="true" Enabled="false" DataIndex="Maker" />
                            <ext:NumberField runat="server" ID="txtPrice" Flex="1" ReadOnly="true" Enabled="false" DataIndex="Price" />
                        </Items>
                    </ext:CompositeField>
                    <ext:NumberField runat="server" ID="txtProductSum" FieldLabel="商品剩余数量" ReadOnly="true" DataIndex="Sum" />
                </Items>
            </ext:FormPanel>
            <ext:FormPanel ID="fpProductIn" runat="server" AutoHeight="true" Title="商品入库信息" Padding="5"
                MonitorResize="true" LabelWidth="60">
                <Items>
                    <ext:NumberField runat="server" FieldLabel="数量" ID="txtSum" Width="100" />
                    <ext:Hidden runat="server" ID="txtProductID" DataIndex="Productid" />
                </Items>
                <Buttons>
                    <ext:Button ID="btnSave" runat="server" Text=" 入 库 " Icon="DatabaseSave">
                        <DirectEvents>
                            <Click OnEvent="btnSave_Click">
                                <EventMask ShowMask="true" Msg="正在保存数据，请稍后..." />
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                </Buttons>
            </ext:FormPanel>
        </Items>
    </ext:Viewport>
    <ext:Window ID="winDetail" runat="server" Title="商品信息" CloseAction="Hide" Layout="fit"
        Frame="true" Modal="true" Hidden="true" Width="300" Height="300" Resizable="false">
        <Items>
            <ext:GridPanel ID="gpProducts" runat="server" StoreID="storeProduct" Padding="0"
                Margins="0 0 0 0" Region="Center" Frame="true" AutoExpandColumn="maker">
                <TopBar>
                    <ext:Toolbar ID="tblGrid" runat="server">
                        <Items>
                            <ext:TextField Width="150" ID="txtSearchName" LabelWidth="60" runat="server" FieldLabel="商品名称" />
                            <ext:Button ID="btnSearchName" runat="server" Text="查询" Icon="DatabaseStart">
                                <DirectEvents>
                                    <Click OnEvent="SearchClick">
                                        <EventMask ShowMask="true" Msg="数据查询中..." Target="CustomTarget" CustomTarget="#{gpProducts}" />
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <ColumnModel ID="cmGrid" runat="server">
                    <Columns>
                        <ext:RowNumbererColumn />
                        <ext:Column Header="商品名称" Width="90" DataIndex="PRODUCTNAME">
                        </ext:Column>
                        <ext:Column Header="商品类型" Width="90" DataIndex="PRODUCTTYPE">
                        </ext:Column>
                        <ext:Column Header="制造商" ColumnID="maker" Width="90" DataIndex="MAKER">
                        </ext:Column>
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel ID="rowSelModeNote" runat="server" />
                </SelectionModel>
                <LoadMask ShowMask="true" />
                <DirectEvents>
                    <RowDblClick OnEvent="productSelect">
                        <EventMask ShowMask="true" Msg="数据提交中..." Target="CustomTarget" CustomTarget="#{gpProducts}" />
                        <ExtraParams>
                            <ext:Parameter Name="productid" Value="rowSelModeNote.getSelected().id" Mode="Raw" />
                        </ExtraParams>
                    </RowDblClick>
                </DirectEvents>
            </ext:GridPanel>
        </Items>
        <Buttons>
            <ext:Button ID="btnClose" runat="server" Text=" 关 闭 " OnClientClick="#{winDetail}.hide()" />
        </Buttons>
    </ext:Window>
    </form>
</body>
</html>
